
class Solution:
    #二分查找
    def binarySearch(self,nums,target):
        return self.search(nums,0,len(nums)-1,target)
    def search(self,nums,start,end,target):
        if start > end:
            return -1
        mid = (start + end)//2
        if nums[mid] > target:
            self.search(nums,start,mid,target)
        if nums[mid] == target:
            return mid
        if nums[mid] < target:
            self.search(nums,mid,end,target)

if __name__ == '__main__':
    nums = [1,3,4,5,7,9,21]
    target = 5
    solution = Solution()
    print(solution.binarySearch(nums,target))